package com.smasher.print.dw;

import android.content.Context;
import android.util.Log;

import com.smasher.print.core.PrintDelegate;

import org.json.JSONObject;

import dw.printer.Printer;

public class PrinterDW implements PrintDelegate {

    public static final String TAG = "PrinterDW";

    private Printer printer;

    private ConnectDW connectDW;

    private PrintContent printContent;

    public PrinterDW(Context context) {
        printer = new Printer(context);
        connectDW = new ConnectUSB(context, printer);
        connectDW.start(context);
        printContent = new PrintContent(printer);
    }

    @Override
    public void printText(JSONObject json) {
        this.printContent.printText(json);
    }

    @Override
    public void connPrint(Context context) {
        connectDW.connPrint(context);
    }

    @Override
    public void disConnPrint(Context context) {
        connectDW.disConnPrint(context);
    }

    @Override
    public boolean isUnConnect(Context context) {
        Log.i(TAG, "isUnConnect: ");
        return connectDW.isUnConnect(context);
    }

    @Override
    public void release(Context context) {
        connectDW.stop(context);
    }
}
